﻿using Microsoft.AspNetCore.Mvc;
using RxxAdmin.Common;
using RxxAdmin.Model.Logs;
using RxxAdmin.Model.ViewModels;
using RxxAdmin.Model;
using RxxAdmin.IServices;

namespace RxxAdmin.Api.Controllers.log;

public class OperationLogController: BaseApiController
{
    private readonly IOperationLogService _operationLogService;

    public OperationLogController(IOperationLogService operationLogService)
    {
        _operationLogService = operationLogService;
    }
    [HttpPost]
    [OperLog("获取全部操作记录", OperEnum.Select)]
    public async Task<MessageModel<PageModel<OperationLog>>> PageList(OperationLogPageIn input)
    {
        if (string.IsNullOrEmpty(input.Title) || string.IsNullOrWhiteSpace(input.Title))
        {
            input.Title = "";
        }
        var loginLogs = await _operationLogService.QueryPageSplit(
                    a => a.Title != null && a.Title.Contains(input.Title),
                    input.DateTimeStart.ToLocalTime(),
                    input.DateTimeEnd.ToLocalTime(),
                    input.PageNum,
                    input.PageSize,
                    " Id desc ");
        return Success(loginLogs);
    }
}
